<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<jsp:useBean id="b" class="jwj8508.j2ee.basic.projectv5.model.BoardVO" />
<jsp:setProperty property="*" name="b" />
<c:set var="b" value="${bdao.viewBoard(b) }" />
<c:set var="br" value="\r\n" />

<style type="text/css">			
	#view {	width: 75%;	margin: 0 auto;	}
	label {	display: inline-block; width: 10%; text-align: right;
		font-weight: bold; margin: 0 10px 10px 0; }
	.contents {	display: inline-block; width: 80%; height: 350px;
		overflow: auto;	padding: 0 10px 10px 10px; }
	.dragup { vertical-align: top; }
</style>
<div id="content">
	<h2>게시판 본문글</h2>
	<div id="view">
		<div><label>제목</label><span>${ b.title }</span></div>
		<div><label>작성자</label><span>${ b.uid }</span></div>
		<div><label>작성일</label><span>${ b.wdate }</span></div>
		<div><label>조회수</label><span>${ b.reades }</span></div>
		<div>
			<label class="dragup">본문</label>
			<span class="contents">${ b.contents }</span>
		</div>
		<div>
			<label> </label>
			<c:if test="${ not empty sessionScope.uid and sessionScope.uid eq b.uid }">
				<button type="button" id="updbtn">수정하기</button>
				<button type="button" id="delbtn">삭제하기</button>
			</c:if>
			<c:if test="${ empty sessionScope.uid }">
				<h4 style="color: red;">로그인하세요</h4>
			</c:if>
		</div>
	</div>
</div> <!-- content -->		
<script type="text/javascript">	
	try {
		var deletebtn = document.getElementById("delbtn");
		deletebtn.onclick = function(){
			if(confirm('정말 삭제하시겠습니까?')) {					
				location.href="?action=deleteok&bdno=${b.bdno }";
			}
		};
		var updatebtn = document.getElementById("updbtn");
		updatebtn.onclick = function(){
			if(confirm('정말 수정하시겠습니까?')) {
				//alert("수정 되었습니다.");
				//location.href="update.html";
				location.href="?action=update&bdno=${b.bdno }";
			}
		};
	} catch (e) {}
	//본문 줄바꿈 처리
	var c = document.getElementsByClassName("contents");
	//alert(c[0].innerHTML);
	c[0].innerHTML = c[0].innerHTML.replace( new RegExp('\r?\n', 'g'), "<br />" );
</script>		